return {
  "neovim/nvim-lspconfig",
  event = { "BufReadPre", "BufNewFile" },
  dependencies = {
    {
      "williamboman/mason-lspconfig.nvim",
      dependencies = "williamboman/mason.nvim",
    },
    "hrsh7th/cmp-nvim-lsp",
    "jubnzv/virtual-types.nvim",
    { "antosha417/nvim-lsp-file-operations", config = true },
    { "folke/neodev.nvim",                   opts = {} },
    {
      "dmmulroy/ts-error-translator.nvim",
      config = true,
      ft = { "typescript", "typescriptreact", "javascript", "javascriptreact", "vue" },
    },
  },
  config = function()
    local lspconfig = require("lspconfig")
    local mason_lspconfig = require("mason-lspconfig")
    local cmp_nvim_lsp = require("cmp_nvim_lsp")

    local home = os.getenv("HOME")
    local map = vim.keymap.set -- for conciseness
    local tsdk_path = home .. "/n/lib/node_modules/typescript/lib"
    -- local vt = require("virtualtypes")

    --- Capabilities
    local capabilities = vim.tbl_deep_extend(
      "force",
      vim.lsp.protocol.make_client_capabilities(),
      cmp_nvim_lsp.default_capabilities()
    )
    -- -- ufo
    -- capabilities.textDocument.foldingRange = {
    --   dynamicRegistration = false,
    --   lineFoldingOnly = true,
    -- }
    -- ---@diagnostic disable-next-line: inject-field
    -- capabilities.offsetEncoding = { "utf-16" }
    -- -- snippets
    -- local _snippet_capabilities = vim.lsp.protocol.make_client_capabilities()
    -- ---@diagnostic disable-next-line: inject-field
    -- _snippet_capabilities.textDocument.completion.completionItem.snippetSupport = true
    -- local snippet_capabilities = vim.tbl_extend("keep", capabilities, _snippet_capabilities)
    --
    -- -- Diagnostic
    -- vim.diagnostic.config({
    --   virtual_text = false,
    --   virtual_lines = {
    --     only_current_line = true,
    --   },
    --   update_in_insert = false,
    --   underline = true,
    --   severity_sort = true,
    --   float = {
    --     focusable = true,
    --     border = "rounded",
    --     header = "",
    --     prefix = "",
    --   },
    -- })
    --
    -- ---@diagnostic disable-next-line: duplicate-set-field
    -- vim.lsp.handlers["textDocument/hover"] = function(_, result, ctx, config)
    --   if not (result and result.contents) then
    --     return
    --   end
    --   config = config or {}
    --   config.border = "rounded"
    --   vim.lsp.handlers.hover(_, result, ctx, config)
    -- end
    -- vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
    --   border = "rounded",
    -- })
    -- ---@diagnostic disable-next-line: duplicate-set-field
    -- vim.lsp.handlers["textDocument/publishDiagnostics"] = function(err, result, ctx, config)
    --   local ts_lsp = { "tsserver", "angularls", "volar" }
    --   local clients = vim.lsp.get_clients({ id = ctx.client_id })
    --   if vim.tbl_contains(ts_lsp, clients[1].name) then
    --     local filtered_result = {
    --       diagnostics = vim.tbl_filter(function(d)
    --         return d.severity == 1
    --       end, result.diagnostics),
    --     }
    --     require("ts-error-translator").translate_diagnostics(err, filtered_result, ctx, config)
    --   end
    --   vim.lsp.diagnostic.on_publish_diagnostics(err, result, ctx, config)
    -- end

    vim.api.nvim_create_autocmd("LspAttach", {
      group = vim.api.nvim_create_augroup("UserLspConfig", {}),
      callback = function(ev)
        -- Buffer local mappings.
        -- See `:help vim.lsp.*` for documentation on any of the below functions
        local opts = { buffer = ev.buf, silent = true }

        -- set keybinds
        opts.desc = "Show LSP references"
        map("n", "gR", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references

        opts.desc = "Go to declaration"
        map("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration

        opts.desc = "Show LSP definitions"
        map("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions

        opts.desc = "Show LSP implementations"
        map("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations

        opts.desc = "Show LSP type definitions"
        map("n", "gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions

        opts.desc = "See available code actions"
        map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection

        opts.desc = "Smart rename"
        map("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename

        opts.desc = "Show buffer diagnostics"
        map("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show  diagnostics for file

        opts.desc = "Show line diagnostics"
        map("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line

        opts.desc = "Go to previous diagnostic"
        map("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer

        opts.desc = "Go to next diagnostic"
        map("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer

        opts.desc = "Show documentation for what is under cursor"
        map("n", "gk", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor

        opts.desc = "Restart LSP"
        map("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
      end,
    })

    -- Change the Diagnostic symbols in the sign column (gutter)
    -- (not in youtube nvim video)
    local signs = { Error = " ", Warn = " ", Hint = "󰠠 ", Info = " " }
    for type, icon in pairs(signs) do
      local hl = "DiagnosticSign" .. type
      vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
    end

    -- used to enable autocompletion (assign to every lsp server config)
    -- local capabilities = cmp_nvim_lsp.default_capabilities()

    local servers = {
      -- typescript
      tsserver = {
        init_options = {
          typescript = {
            tsdk = tsdk_path,
          },
          plugins = {
            {
              name = "@vue/typescript-plugin",
              location = home .. "/n/lib/node_modules/@vue/typescript-plugin",
              language = {
                "typescript",
                "vue"
              },
            }
          }
        },
        filetypes = {
          "javascript",
          "javascriptreact",
          "typescript",
          "typescriptreact",
          "vue",
        },
      },
      -- volar
      volar = {
        init_options = {
          typescript = {
            tsdk = tsdk_path,
          },
          vue = {
            hybridMode = false,
          }
        },
        filetypes = {
          "vue",
        }
      },
      -- lua
      lua_ls = {
        settings = {
          Lua = {
            -- make the language server recognize "vim" global
            diagnostics = {
              globals = { "vim" },
            },
            completion = {
              callSnippet = "Replace",
            },
          },
        },
      }
    }

    mason_lspconfig.setup_handlers({
      function(server_name)
        local server = servers[server_name] or {}
        server.capabilities = capabilities
        lspconfig[server_name].setup(server)
      end,
    })
  end,
}
